<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="技术类型" prop="technologyId">
        <el-select
          v-model="queryParams.technologyId"
          placeholder="技术类型"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in typeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="面试官名称" prop="dutyPerson">
        <el-input
          v-model="queryParams.dutyPerson"
          placeholder="请输入面试官"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQueryFn"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryFn">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQueryFn">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAddFn"
          v-hasPermi="['pmp:Interviewer:add']"
        >新增面试官</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDeleteFn"
          v-hasPermi="['pmp:Interviewer:remove']"
        >删除</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExportFn"
          v-hasPermi="['pmp:Interviewer:export']"
        >发送周报</el-button>
      </el-col> -->
    </el-row>

    <el-table v-loading="loading" :data="InterviewerList" @selection-change="handleSelectionChangeFn">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="面试官名称" prop="userName" width="220" />
      <el-table-column label="技术类型" prop="technologyName" :show-overflow-tooltip="true" width="250">
        <template slot-scope="scope">
          <span>{{ scope.row.technologyName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="时间" prop="updateTime" :show-overflow-tooltip="true"/>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getListFn"
    />

    <Interviewer-detail ref='detail' ></Interviewer-detail>
  </div>
</template>

<script>
  import { apiInterviewList, apiInterviewDel } from "@/api/pmp/api.recruit";
  // import { apiTreeselect as menuTreeselect, apiRoleMenuTreeselect } from "@/api/system/menu"; //接入项目管理接口
  import InterviewerDetail from './components/Interviewer.detail.vue';

  export default {
    name: "Interviewer", //面试官管理页面
    components: {
      InterviewerDetail
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 表格数据
        InterviewerList: [],
        // 详情页数据
        InterviewerData: {
          title: "添加面试官",
          formData: undefined
        },
        // 技术类型数据字典
        typeOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          roleName: undefined,
          roleKey: undefined,
          status: undefined
        },
        defaultProps: {
          children: "children",
          label: "label"
        }
      };
    },
    created() {
      this.getListFn();
      this.apiGetDicts("technology_post_type").then(response => {
        this.typeOptions = response.data;
      });
    },
    methods: {
      /** 查询面试官列表 */
      getListFn() {
        this.loading = true;
        apiInterviewList(this.queryParams).then(
          response => {
            this.InterviewerList = response.rows;
            this.total = response.total;
            this.loading = false;
          }
        );
      },
      /** 搜索按钮操作 */
      handleQueryFn() {
        this.queryParams.pageNum = 1;
        this.getListFn();
      },
      /** 重置按钮操作 */
      resetQueryFn() {
        this.dateRange = [];
        this.resetForm("queryForm");
        this.handleQueryFn();
      },
      // 多选框选中数据
      handleSelectionChangeFn(selection) {
        this.ids = selection.map(item => item.id);
        this.single = selection.length!=1;
        this.multiple = !selection.length;
      },
      /** 新增按钮操作 */
      handleAddFn() {
        this.open = true;
        this.$refs.detail.openDetail();
      },
      /** 删除按钮操作 */
      handleDeleteFn(row) {
        const id = row.id || (this.ids || []).join(',');
        this.$confirm('是否确认删除选中的面试官?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return apiInterviewDel(id);
        }).then(() => {
          this.getListFn();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      }
    }
  };
</script>
